import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';

import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import legacy from '@vitejs/plugin-legacy';

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [
    react(),
    createSvgIconsPlugin({
      // 指定需要缓存的图标文件夹
      iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], // 指定项目内图标路径
      // 指定symbolId格式
      symbolId: 'icon-[dir]-[name]'
    }),
    legacy({
      targets: ['defaults', 'not IE 11']
    })
  ],
  resolve: {
    alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }]
  },
  build: {
    target: ['es2015', 'chrome63']
  },
  server: {
    host: '0.0.0.0' // Network: use --host to expose 可以让Network访问
  }
});
